home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Grafik / Misc / ImageEnginer / ARexx / Batch / External_ieb / WhirlGIF.ieb < prev   
Encoding:
Text File  |  1997-02-02  |  6.4 KB  |  217 lines

  1. /*
  2. ** $VER: WhirlGIF.ieb 1.2, IE Arexx script
  3. ** Image Engineer Batch Processing script
  4. ** Copyright © by Patrik M Nydensten
  5. ** 25/1 1997 Stockholm/Sweden
  6. **
  7. ** Merges gif pictures to a gif animation, using the program WhirlGif 2.01.
  8. ** WhirlGIF is assumed to be within the search path.  WhirlGIF can be
  9. ** downloaded from AmiNet (AmiNet:gfx/conv/whirlgif201.lha).
  10. */
  11.  
  12. options results
  13. signal on error
  14.  
  15. parse arg input command
  16. input = upper(strip(input))
  17. address 'IMAGEENGINEER'
  18.  
  19. select  /* Required batch script commands */
  20.   when input = 'INFO' then    return get_info()
  21.   when input = 'CONFIG' then  return get_config(command)
  22.   when input = 'PROCESS' then return process_image(command)
  23.   otherwise do
  24.     'REQUEST' '"Failure in call to batch script!"' '" Quit "'
  25.     return '<ERROR>'
  26.   end
  27. end
  28.  
  29. exit 0
  30.  
  31. /* Required "Get_info" procedure  ------------------------------------ */
  32. /* S = SECONDARY, A = ALPHA, 1 = Single file, 2 = Multiple files       */
  33.  
  34. get_info:
  35.   back = 'OK F'
  36. return back
  37.  
  38. /* Required "Get_config" procedure  ---------------------------------- */
  39.  
  40. get_config:
  41.   parse arg '"'command'"'
  42.  
  43.   loops=99999 ; t_value=15
  44.  
  45.   if command ~= '' then parse var command '#'disp_method '#'loops t_value '#'timingQ
  46.  
  47.   'IE_TO_FRONT'
  48.  
  49.   form = 'FORM "WhirlGif" " OK | Cancel "'
  50.  
  51.   if command = '' then do
  52.     form = form||' CYCLE,"Disposal method:","None - no disposal specified (normal)|'||,
  53.     'Back - clear to background (may flicker)|Prev - ues previous frame data|'||,
  54.     'Not - do not dispose (image overlay)",0',
  55.     ' INTEGER,"Loops",0,99999,99999,SLIDER'
  56.   end
  57.  
  58.   form = form||' INTEGER,"Frame timing (1/100 s)",1,10000,'t_value',SLIDER'
  59.  
  60.   if command = '' then do
  61.     form = form||' CHECKBOX,"Ask for new new frame timing for all frames?",1'
  62.     form
  63.     parse var result ok disp_method loops t_value timingQ .
  64.     if ok = 0 then return '<ERROR>'
  65.   end
  66.   else do
  67.     form
  68.     parse var result ok t_value .
  69.     if ok = 0 then return '<ERROR>'
  70.  
  71.     disp_method = 'none'
  72.     loops = 'none'
  73.     timingQ = 'none'
  74.   end
  75.  
  76.   back =  '#'disp_method '#'loops t_value '#'timingQ
  77. return back
  78.  
  79. /* Required "Process_image" procedure  ------------------------------- */
  80.  
  81. process_image:
  82.   parse arg '"'src_image'"' '"'dst_image'"' '"'options'"' '"'frame':'num_frames'"'
  83.   parse var options '#'disp_method '#'loops t_value '#'timingQ .
  84.  
  85. /* first frame only  -------------------------------- */
  86.  
  87.   if frame = 1 then do
  88.     if strip(getclip(wgif_tval)) = '' then call setclip(wgif_tval,strip(t_value))
  89.     if ~open('df','t:WG.df','W') then return '<ERROR>'
  90.     call writeln('df','** WhirlGIF.ieb datafile **')
  91.     call close('df')
  92.   end
  93.  
  94. /* all frames  -------------------------------------- */
  95.  
  96.   if ~open('df','t:WG.df','A') then return '<ERROR>'
  97.  
  98.   t_value = strip(t_value)
  99.  
  100.   if timingQ = 1 then do
  101.     'REQUEST' '"Use frame timing value:' t_value d2c(10)||,
  102.     'for frame' frame 'of' num_frames '?"' '" Yes, use' t_value '| No, use' getclip(wgif_tval) '| No, set new "'
  103.     if result = 0 then do
  104.  
  105.       if datatype(getclip(wgif_tval),'N') then t_value = getclip(wgif_tval)
  106.  
  107.       'GET_NUMBER' '"Set frame timing value for frame' frame 'of' num_frames'"' '1 10000' '" OK "' t_value 'SLIDER'
  108.       t_value = result
  109.  
  110.       call setclip(wgif_tval,t_value)
  111.     end
  112.     if result = 2 then if datatype(getclip(wgif_tval),'N') then t_value = getclip(wgif_tval)
  113.   end
  114.  
  115.   call writeln('df',t_value)
  116.   call writeln('df',src_image)
  117.   call close('df')
  118.  
  119. /* last frame only  -------------------------------- */
  120.  
  121.   if frame = num_frames then do
  122.     if exists('t:WG.df') then do
  123.       if ~open('df','t:WG.df','R') then return '<ERROR>'
  124.     end
  125.     else return '<ERROR>'
  126.     call readln('df')
  127.  
  128.     if ~open('exes','t:WG.script','W') then return '<ERROR>'
  129.  
  130.     select
  131.       when disp_method = 0 then disp_method = 'none'
  132.       when disp_method = 1 then disp_method = 'back'
  133.       when disp_method = 2 then disp_method = 'prev'
  134.       when disp_method = 3 then disp_method = 'not'
  135.       otherwise return '<ERROR>'
  136.     end
  137.  
  138.     call writeln('exes','Cd' '"'get_path(dst_image)'"')
  139.     call writech('exes','Whirlgif -v -o "'get_file(get_base(dst_image))||,
  140.       '" -disp' disp_method '-loop' loops)
  141.  
  142.     com_string = '' ; prev_tval = -1 ; ifiles = 0
  143.  
  144.     do while ~eof('df')
  145.       read_tval = readln('df')
  146.       if eof('df') then leave
  147.  
  148.       if read_tval ~= prev_tval then do
  149.         ifiles = ifiles + 1
  150.         call writech('exes',' -time' read_tval '-i t:WG.i'ifiles)
  151.         if ~open('ifile','t:WG.i'ifiles,'W') then return '<ERROR>'
  152.       end
  153.       else if ~open('ifile','t:WG.i'ifiles,'A') then return '<ERROR>'
  154.  
  155.       call writeln('ifile',readln('df'))
  156.       call close('ifile')
  157.  
  158.       prev_tval = read_tval
  159.     end /* while */
  160.  
  161.     call close('exes')
  162.     call close('df')
  163.  
  164.     'WB_TO_FRONT'
  165.  
  166.     address 'COMMAND' 'execute t:WG.script'
  167.     if RC~=0 then 'REQUEST' '"WhirlGIF returned error code while processing your'd2c(10)||,
  168.                              'gif images. Please see output window on Workbench."',
  169.                              '" OK "'
  170.     'IE_TO_FRONT'
  171.  
  172.   end  /* last frame */
  173.  
  174.   back = 'OK'
  175. return back
  176.  
  177. /* Internal procedures  ---------------------------------------------- */
  178.  
  179. get_base:
  180.   parse arg get_base_in
  181.   if lastpos('.',get_base_in) ~= 0 then get_base_back = substr(get_base_in,1,lastpos('.',get_base_in)-1)
  182.   else get_base_back = get_base_in
  183. return get_base_back
  184.  
  185. get_path:
  186.   parse arg get_path_in
  187.   if lastpos('/',get_path_in) ~= 0 then get_path_back = substr(get_path_in,1,lastpos('/',get_path_in))
  188.   else if lastpos(':',get_path_in) ~= 0 then get_path_back = substr(get_path_in,1,lastpos(':',get_path_in))
  189.   else get_path_back = ''
  190. return get_path_back
  191.  
  192. get_file:
  193.   parse arg get_file_in
  194.   if lastpos('/',get_file_in) ~= 0 then get_file_back = substr(get_file_in,1+lastpos('/',get_file_in))
  195.   else if lastpos(':',get_file_in) ~= 0 then get_file_back = substr(get_file_in,1+lastpos(':',get_file_in))
  196.   else get_file_back = get_file_in
  197. return get_file_back
  198.  
  199. /*******************************************************************/
  200. /* This is where control goes when an error code is returned by IE */
  201. /* It puts up a message saying what happened and on which line     */
  202. /*******************************************************************/
  203.  
  204. error:
  205. if RC=5 then do
  206.     IE_TO_FRONT
  207.     LAST_ERROR
  208.     'REQUEST "'||RESULT||'"'
  209. end
  210. else do
  211.     IE_TO_FRONT
  212.     LAST_ERROR
  213.     'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!'
  214. end
  215.  
  216. return '<ERROR>'
  217.